package com.ruoyi.web.controller.huiyuan;

import java.util.List;

import com.ruoyi.system.service.IHynfjfdkService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Hynfjfdk;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 会员年费积分抵扣 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/hynfjfdk")
public class HynfjfdkController extends BaseController
{
    private String prefix = "system/hynfjfdk";
	
	@Autowired
	private IHynfjfdkService hynfjfdkService;
	
	@RequiresPermissions("system:hynfjfdk:view")
	@GetMapping()
	public String hynfjfdk()
	{
	    return prefix + "/hynfjfdk";
	}
	
	/**
	 * 查询会员年费积分抵扣列表
	 */
	@RequiresPermissions("system:hynfjfdk:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Hynfjfdk hynfjfdk)
	{
		startPage();
        List<Hynfjfdk> list = hynfjfdkService.selectHynfjfdkList(hynfjfdk);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出会员年费积分抵扣列表
	 */
	@RequiresPermissions("system:hynfjfdk:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Hynfjfdk hynfjfdk)
    {
    	List<Hynfjfdk> list = hynfjfdkService.selectHynfjfdkList(hynfjfdk);
        ExcelUtil<Hynfjfdk> util = new ExcelUtil<Hynfjfdk>(Hynfjfdk.class);
        return util.exportExcel(list, "hynfjfdk");
    }
	
	/**
	 * 新增会员年费积分抵扣
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存会员年费积分抵扣
	 */
	@RequiresPermissions("system:hynfjfdk:add")
	@Log(title = "会员年费积分抵扣", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Hynfjfdk hynfjfdk)
	{		
		return toAjax(hynfjfdkService.insertHynfjfdk(hynfjfdk));
	}

	/**
	 * 修改会员年费积分抵扣
	 */
	@GetMapping("/edit/{hynfjfdkId}")
	public String edit(@PathVariable("hynfjfdkId") Integer hynfjfdkId, ModelMap mmap)
	{
		Hynfjfdk hynfjfdk = hynfjfdkService.selectHynfjfdkById(hynfjfdkId);
		mmap.put("hynfjfdk", hynfjfdk);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存会员年费积分抵扣
	 */
	@RequiresPermissions("system:hynfjfdk:edit")
	@Log(title = "会员年费积分抵扣", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Hynfjfdk hynfjfdk)
	{		
		return toAjax(hynfjfdkService.updateHynfjfdk(hynfjfdk));
	}
	
	/**
	 * 删除会员年费积分抵扣
	 */
	@RequiresPermissions("system:hynfjfdk:remove")
	@Log(title = "会员年费积分抵扣", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(hynfjfdkService.deleteHynfjfdkByIds(ids));
	}
	
}
